<style>
  .error {color : red}
</style>
<div class="container-fluid p-t-10">
  <ol class="breadcrumb" style="font-weight: 700;margin-bottom: 10px">
    <li class="active">个人信息</li>
  </ol>
  <div class="row">
    <div class="col-lg-12">
      <div class="card">

        <div class="card-body">
          <h1>个人信息</h1>
          <form id="add-form" action="" method="post" class="row">
            <div class="form-group col-md-12 hide">
              <label for="id">编号</label>
              <input type="text" class="form-control" id="id" name="id" readonly value="{$data? $data.id:''}"/>
            </div>

            <div class="form-group col-md-12">
              <label for="username">用户名</label>
              <input type="text" class="form-control" id="username" name="username" value="{$data.username}" readonly />
            </div>

              <div class="form-group col-md-12">
                  <label for="phone">电话号码</label>
                  <input type="text" class="form-control" id="phone" name="phone" value="{$data.phone}" readonly />
              </div>

              <div class="form-group col-md-12">
                  <label for="qq">qq</label>
                  <input type="text" class="form-control" id="qq" name="qq" value="{$data.qq}"  />
              </div>

              <div class="form-group col-md-12">
                  <label for="email">邮箱</label>
                  <input type="text" class="form-control" id="email" name="email" value="{$data.email}"  />
              </div>

              <div class="form-group col-md-12">
                  <label for="address">地址</label>
                  <textarea class="form-control" id="address" name="address" rows="4" placeholder="地址..">{$data.address}</textarea>
              </div>

              <div class="form-group col-md-12">
                  <label for="desc">备注</label>
                  <textarea class="form-control" id="desc" name="desc" rows="4" placeholder="备注..">{$data.desc}</textarea>
              </div>

            <div class="form-group col-md-12">
              <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script>

  $(function(){
    $("#add-form").validate({
        submitHandler:function(){
            var id = $('#id').val();
            var qq = $('#qq').val();
            var email = $('#email').val();
            var address = $('#address').val();
            var desc = $('#desc').val();

            console.log(id,qq,email,address,desc);

            $._ajax({
                url:'/index/userinfo.html',
                type:'post',
                data:{
                    id:id,
                    qq:qq,
                    email:email,
                    address:address,
                    desc:desc,
                }
            }).done(function(data){
                if(data){
                    lightyear.notify('保存成功~', 'success');
                }else{
                    lightyear.notify('保存失败~', 'danger');
                    setTimeout(function() {
                        window.location.reload();
                    }, 1e3);
                }
            });
            return false;
        },
        rules: {
            email: true
      }
    });
  });
</script>


